<template>
	<view>
		<view class="wrapper" v-for="(item,index) in listData" :key="index">
			<view class="info">
				<image style="border-radius: 50%;" :src="item.wx_user.avatarUrl" mode="aspectFill"></image>
				<view class="word">
					<view class="name">{{item.wx_user.nickName}}</view> 
				</view>
			</view>
			<view class="describle">{{item.content}}，</view>
			 
		</view>
	</view>
</template>

<script>
	import { CommentsList } from '@/utils/request.js'
	
	export default {
		data() {
			return {
				p:0,
				totalPage:0,
				userInfo:JSON.parse(uni.getStorageSync('userInfo')||'{}'),
				id:'',
				listData:[]
			}
		},
		methods: {
			// CommentsList 评论列表
			async CommentsList(data){
				return await CommentsList(data)
			},
			// 评论列表
			getTalkList(){
				let data={
					user_dynamic_id:this.id,
					p:this.p,
					n:15,
					token:this.userInfo.token
				}
				// if((this.type+1)==3){
				// 	data=Object.assign(data,{token:this.userInfo.token})
				// }
				this.CommentsList(data).then(res=>{
					console.log(res)
					if(res.list&&res.list.length>0){
						this.totalPage=Math.ceil(res.count/15)
						this.listData=[...this.listData,...res.list]
						
					}
				})
				
				// talkList
			},
		},
		onLoad(option) {
			if(option.id){
				this.id=option.id
				this.getTalkList()
			}
		},
		onReachBottom() {
			if(this.p<this.totalPage-1){
				this.p++
				this.getTalkList()
			}
		}
	}
</script>

<style lang="scss">
.wrapper{
	border-bottom: 1px solid #C0C0C0;
		padding: 62rpx 30rpx 30rpx;
		.info{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			margin-bottom: 20rpx;
			image{
				width: 80rpx;
				height: 80rpx;
				margin-right: 20rpx;
			}
			.word{
				display: flex;
				justify-content: flex-start;
				align-items: flex-start;
				flex-direction: column;
				.name{
					font-size: 30rpx;
					font-family: PingFang SC;
					font-weight: 600;
					line-height: 42rpx;
					color: #1A1A1A;	
					margin-bottom: 8rpx;
				}
				.time{
					font-size: 22rpx;
					font-family: 苹方-简;
					font-weight: normal;
					line-height: 30rpx;
					color: #888888;
				}
			}
		}
		.describle{
			font-size: 28rpx;
			font-family: 苹方-简;
			font-weight: normal;
			line-height: 42rpx;
			color: #1A1A1A;
			margin-bottom: 8rpx;
			word-break: break-all;
		}
		.imgList{
			display: flex;
			justify-content: flex-start;
			align-items: center;
			flex-flow: row wrap;
			image{
				width: 224rpx;
				height: 224rpx;
				margin-right: 8rpx;
				margin-bottom: 8rpx;
			}
			image:nth-child(3n){margin-right: 0;}
		}
	}
</style>
